<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
    <th:block th:include="include :: header('新增元数据创建日志')" />
</head>
<body class="white-bg">
    <div class="wrapper wrapper-content animated fadeInRight ibox-content">
        <form class="form-horizontal m" id="form-tblog-add">
            <h4 class="form-header h4">元数据创建日志信息</h4>
            <div class="form-group">    
                <label class="col-sm-3 control-label">表名：</label>
                <div class="col-sm-8">
                    <input name="cdTb" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">参数：</label>
                <div class="col-sm-8">
                    <textarea name="param" class="form-control"></textarea>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">数据类型：</label>
                <div class="col-sm-8">
                    <input name="euParamtp" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">方法名：</label>
                <div class="col-sm-8">
                    <input name="method" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">备注：</label>
                <div class="col-sm-8">
                    <input name="des" class="form-control" type="text">
                </div>
            </div>
            <h4 class="form-header h4">元数据日志明细信息</h4>
            <div class="row">
                <div class="col-sm-12">
                    <button type="button" class="btn btn-white btn-sm" onclick="addRow()"><i class="fa fa-plus"> 增加</i></button>
                    <button type="button" class="btn btn-white btn-sm" onclick="sub.delRow()"><i class="fa fa-minus"> 删除</i></button>
                    <div class="col-sm-12 select-table table-striped">
                        <table id="bootstrap-table"></table>
                    </div>
                </div>
            </div>
        </form>
    </div>
    <th:block th:include="include :: footer" />
    <script th:inline="javascript">
        var prefix = ctx + "system/tblog"
        $("#form-tblog-add").validate({
            focusCleanup: true
        });

        function submitHandler() {
            if ($.validate.form()) {
                $.operate.save(prefix + "/add", $('#form-tblog-add').serialize());
            }
        }

        $(function() {
            var options = {
                pagination: false,
                showSearch: false,
                showRefresh: false,
                showToggle: false,
                showColumns: false,
                sidePagination: "client",
                columns: [{
                    checkbox: true
                },
                {
                    field: 'index',
                    align: 'center',
                    title: "序号",
                    formatter: function (value, row, index) {
                    	var columnIndex = $.common.sprintf("<input type='hidden' name='index' value='%s'>", $.table.serialNumber(index));
                    	return columnIndex + $.table.serialNumber(index);
                    }
                },
                {
                    field: 'na',
                    align: 'center',
                    title: '名称',
                    formatter: function(value, row, index) {
                        var html = $.common.sprintf("<input class='form-control' type='text' name='mdMedTblogItemList[%s].na' value='%s'>", index, value);
                        return html;
                    }
                },
                {
                    field: 'sqlExec',
                    align: 'center',
                    title: 'SQL',
                    formatter: function(value, row, index) {
                        var html = $.common.sprintf("<input class='form-control' type='text' name='mdMedTblogItemList[%s].sqlExec' value='%s'>", index, value);
                        return html;
                    }
                },
                {
                    field: 'euStatus',
                    align: 'center',
                    title: '执行结果',
                    formatter: function(value, row, index) {
                        var html = $.common.sprintf("<input class='form-control' type='text' name='mdMedTblogItemList[%s].euStatus' value='%s'>", index, value);
                        return html;
                    }
                },
                {
                    field: 'des',
                    align: 'center',
                    title: '备注',
                    formatter: function(value, row, index) {
                        var html = $.common.sprintf("<input class='form-control' type='text' name='mdMedTblogItemList[%s].des' value='%s'>", index, value);
                        return html;
                    }
                },
                {
                    field: 'dtSysCre',
                    align: 'center',
                    title: '',
                    formatter: function(value, row, index) {
                        var html = $.common.sprintf("<input class='form-control' type='text' name='mdMedTblogItemList[%s].dtSysCre' value='%s'>", index, value);
                        return html;
                    }
                },
                {
                    field: 'naEmpModi',
                    align: 'center',
                    title: '',
                    formatter: function(value, row, index) {
                        var html = $.common.sprintf("<input class='form-control' type='text' name='mdMedTblogItemList[%s].naEmpModi' value='%s'>", index, value);
                        return html;
                    }
                },
                {
                    field: 'dtSysModi',
                    align: 'center',
                    title: '',
                    formatter: function(value, row, index) {
                        var html = $.common.sprintf("<input class='form-control' type='text' name='mdMedTblogItemList[%s].dtSysModi' value='%s'>", index, value);
                        return html;
                    }
                },
                {
                    field: 'naEmpCre',
                    align: 'center',
                    title: '',
                    formatter: function(value, row, index) {
                        var html = $.common.sprintf("<input class='form-control' type='text' name='mdMedTblogItemList[%s].naEmpCre' value='%s'>", index, value);
                        return html;
                    }
                },
                {
                    title: '操作',
                    align: 'center',
                    formatter: function(value, row, index) {
                        var value = $.common.isNotEmpty(row.index) ? row.index : $.table.serialNumber(index);
                        return '<a class="btn btn-danger btn-xs" href="javascript:void(0)" onclick="sub.delRowByIndex(\'' + value + '\')"><i class="fa fa-remove"></i>删除</a>';
                    }
                }]
            };
            $.table.init(options);
        });

        function addRow() {
            var count = $("#" + table.options.id).bootstrapTable('getData').length;
            var row = {
                index: $.table.serialNumber(count),
                na: "",
                sqlExec: "",
                euStatus: "",
                des: "",
                dtSysCre: "",
                naEmpModi: "",
                dtSysModi: "",
                naEmpCre: "",
            }
            sub.addRow(row);
        }
    </script>
</body>
</html>